﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using NTTDATA.BEENChina.ResultCertification.Config;

namespace NTTDATA.BEENChina.ResultCertification.Checker.Numeric
{
   
    [Serializable]
    [VerfityAttribute(Id = "VerfityD0008", Name = "第N行N列数值项目无记载，其余行列有数值项目记载", CategoryType = EnumCategoryType.数值, Model = true)]
    public class VerfityD0008 : VerfityOneResult
    {

        [Category("设定检查的行列"), Description("要检查的列")]
        public int Column { get; set; }

        [Category("设定检查的行"), Description("要检查的行")]
        public int Row { get; set; }
         

        public override bool CheckResult(List<List<string>> result, string entryCommon)
        {
            bool bresult = false;
            if (entryCommon.Equals("30") || result == null)
            {
                return false;
            }

            Dictionary<int,int> othereCell = null;
            for (int i = 0; i < result.Count; i++)
            {
                var rowResult = result[i];

                for (int j = 0; j < rowResult.Count; j++)
                {
                    if (Row != i || Column != j)
                    {
                        if (othereCell == null)
                        {
                            othereCell = new Dictionary<int, int>();
                        }

                        othereCell.Add(i,j);
                    }

                }
            }

            //指定位置为空白
            bresult =   CheckSpecificRowIsEmpty(result, GetSpeicficResult, false, Row, Column);

            //其余位置非空白
            if (othereCell != null)
            {
                bresult =bresult && othereCell.Any(o => CheckSpecificRowIsEmpty(result, GetSpeicficResult, true, o.Key, o.Value));
            }
            else
            {
                //其余位置是空白时 不符合
                bresult = false;
            }

            if (bresult)
            {
                System.Console.WriteLine("VerfityD0008");
            }

            return bresult;
        }

        protected   string GetSpeicficResult(string colStr)
        {
            var splitEntryResult =
                new Split.SplitEntryResult(
                    ChildImageObject.CategorySetting.DataFormat, colStr);
            var mdRsult = splitEntryResult.GetNumeric();

            return mdRsult;
        }
       
    }
}
